package awt.awt03;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class EventDemo00 {
    Frame fr=new Frame("这里测试事件处理");
    TextField tf=new TextField(30);
    Button ok=new Button("确定");

    private class MyListener implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e){
            tf.setText("Hello World");
        }
    }

    public void init(){
        MyListener myListener=new MyListener();
        ok.addActionListener(myListener);

        fr.add(tf,BorderLayout.NORTH);
        fr.add(ok);

        fr.pack();
        fr.setVisible(true);
    }

    public static void main(String[] args){
        new EventDemo00().init();
    }
}
